﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using BBICMS.Model;
using System.ComponentModel.DataAnnotations.Schema;

namespace BBICMS.Repository.Configuration
{
   public  class PageLangMap : EntityTypeConfiguration<PageLang>
    {
       public PageLangMap()
       {
           this.HasKey(p => p.Id);
            this.Property(p => p.Id)
            .HasColumnName("Id")
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.ToTable("PageLangs");

            this.Property(p => p.Title).HasMaxLength(250).IsOptional();
            this.Property(p => p.Body).IsMaxLength();
            this.Property(p => p.PageId).IsRequired();         


            this.HasRequired(l => l.Page)
           .WithMany(l => l.PageLangs)
           .HasForeignKey(l => l.PageId)
           .WillCascadeOnDelete(true);            

        }
    }
}
